﻿// -----------------------------------------------------------------------------
// 园丁,是个很简单的管理系统
//  gitee:https://gitee.com/hgflydream/Gardener 
//  issues:https://gitee.com/hgflydream/Gardener/issues 
// -----------------------------------------------------------------------------

using Gardener.Core.Client.OperationDialog;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Gardener.Iot.Client.Pages.DeviceView
{
    public partial class GenerateConnectConfig: OperationDialogBase<DeviceDto,bool,IotLocalResource>
    {
        string mqttConnectInfo=string.Empty;
        string tcpConnectInfo=string.Empty;
        string tcpPingContent=string.Empty;
        private void OnTabChange(string key)
        {
            if ("Tcp".Equals(key))
            {

                tcpPingContent = "Heartbeat";
                tcpConnectInfo = $"Login;{this.Options.ClientId};{this.Options.Account};{this.Options.SecretKey}";
            }
            else if ("Mqtt".Equals(key))
            {
                mqttConnectInfo = @$"var mqttClientOptions = new MqttClientOptionsBuilder()
                    .WithClientId(""{this.Options.ClientId}"")
                    .WithTcpServer(""127.0.0.1"", 28889)
                    .WithCredentials(""{this.Options.Account}"", ""{this.Options.SecretKey}"")
                    .Build();";
            }
        }
    }
}
